﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;

using CarFrameWork.Common;
using CarFrameWork.UI.Common;

namespace CarFrameWork.UI.ProductDesign.VehicleMatch
{
    public class usCtlHouQiaoYHPP : BaseControl
    {
        /// <summary> 
        /// 必需的设计器变量。
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// 清理所有正在使用的资源。
        /// </summary>
        /// <param name="disposing">如果应释放托管资源，为 true；否则为 false。</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region 组件设计器生成的代码

        /// <summary> 
        /// 设计器支持所需的方法 - 不要
        /// 使用代码编辑器修改此方法的内容。
        /// </summary>
        private void InitializeComponent()
        {
            this.label8 = new System.Windows.Forms.Label();
            this.dlxjqxs = new System.Windows.Forms.TextBox();
            this.label7 = new System.Windows.Forms.Label();
            this.jdsu = new System.Windows.Forms.TextBox();
            this.label6 = new System.Windows.Forms.Label();
            this.jxsu = new System.Windows.Forms.TextBox();
            this.label4 = new System.Windows.Forms.Label();
            this.zdsb = new System.Windows.Forms.TextBox();
            this.label3 = new System.Windows.Forms.Label();
            this.gdbj = new System.Windows.Forms.TextBox();
            this.label2 = new System.Windows.Forms.Label();
            this.zdzs = new System.Windows.Forms.TextBox();
            this.label1 = new System.Windows.Forms.Label();
            this.zgcs = new System.Windows.Forms.TextBox();
            this.label5 = new System.Windows.Forms.Label();
            this.m_OK = new System.Windows.Forms.Button();
            this.panel4 = new System.Windows.Forms.Panel();
            this.m_Cancel = new System.Windows.Forms.Button();
            this.panel3 = new System.Windows.Forms.Panel();
            this.groupBox2 = new System.Windows.Forms.GroupBox();
            this.label25 = new System.Windows.Forms.Label();
            this.yhjg = new System.Windows.Forms.TextBox();
            this.jjxjqxs = new System.Windows.Forms.TextBox();
            this.panel1 = new System.Windows.Forms.Panel();
            this.panel2 = new System.Windows.Forms.Panel();
            this.groupBox1 = new System.Windows.Forms.GroupBox();
            this.label10 = new System.Windows.Forms.Label();
            this.dlxzb = new System.Windows.Forms.TextBox();
            this.label9 = new System.Windows.Forms.Label();
            this.jjxzb = new System.Windows.Forms.TextBox();
            this.panel4.SuspendLayout();
            this.panel3.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.panel1.SuspendLayout();
            this.panel2.SuspendLayout();
            this.groupBox1.SuspendLayout();
            this.SuspendLayout();
            // 
            // label8
            // 
            this.label8.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label8.Location = new System.Drawing.Point(402, 114);
            this.label8.Name = "label8";
            this.label8.Size = new System.Drawing.Size(265, 24);
            this.label8.TabIndex = 41;
            this.label8.Text = "经济性指标（以循环工况油耗为目标）：";
            // 
            // dlxjqxs
            // 
            this.dlxjqxs.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.dlxjqxs.Location = new System.Drawing.Point(306, 154);
            this.dlxjqxs.Name = "dlxjqxs";
            this.dlxjqxs.Size = new System.Drawing.Size(80, 22);
            this.dlxjqxs.TabIndex = 40;
            // 
            // label7
            // 
            this.label7.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label7.Location = new System.Drawing.Point(23, 154);
            this.label7.Name = "label7";
            this.label7.Size = new System.Drawing.Size(192, 24);
            this.label7.TabIndex = 39;
            this.label7.Text = "动力性加权系数：";
            // 
            // jdsu
            // 
            this.jdsu.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.jdsu.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.jdsu.Location = new System.Drawing.Point(748, 33);
            this.jdsu.Name = "jdsu";
            this.jdsu.ReadOnly = true;
            this.jdsu.Size = new System.Drawing.Size(80, 22);
            this.jdsu.TabIndex = 38;
            // 
            // label6
            // 
            this.label6.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label6.Location = new System.Drawing.Point(403, 33);
            this.label6.Name = "label6";
            this.label6.Size = new System.Drawing.Size(192, 24);
            this.label6.TabIndex = 37;
            this.label6.Text = "减速器速比的极大值：";
            // 
            // jxsu
            // 
            this.jxsu.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.jxsu.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.jxsu.Location = new System.Drawing.Point(307, 33);
            this.jxsu.Name = "jxsu";
            this.jxsu.ReadOnly = true;
            this.jxsu.Size = new System.Drawing.Size(80, 22);
            this.jxsu.TabIndex = 36;
            // 
            // label4
            // 
            this.label4.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label4.Location = new System.Drawing.Point(24, 33);
            this.label4.Name = "label4";
            this.label4.Size = new System.Drawing.Size(192, 24);
            this.label4.TabIndex = 35;
            this.label4.Text = "减速器速比的极小值：";
            // 
            // zdsb
            // 
            this.zdsb.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.zdsb.Location = new System.Drawing.Point(748, 80);
            this.zdsb.Name = "zdsb";
            this.zdsb.Size = new System.Drawing.Size(80, 22);
            this.zdsb.TabIndex = 34;
            // 
            // label3
            // 
            this.label3.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label3.Location = new System.Drawing.Point(403, 80);
            this.label3.Name = "label3";
            this.label3.Size = new System.Drawing.Size(192, 24);
            this.label3.TabIndex = 33;
            this.label3.Text = "变速器最高档传动比：";
            // 
            // gdbj
            // 
            this.gdbj.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.gdbj.Location = new System.Drawing.Point(307, 80);
            this.gdbj.Name = "gdbj";
            this.gdbj.Size = new System.Drawing.Size(80, 22);
            this.gdbj.TabIndex = 32;
            // 
            // label2
            // 
            this.label2.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label2.Location = new System.Drawing.Point(24, 80);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(192, 24);
            this.label2.TabIndex = 31;
            this.label2.Text = "车轮滚动半径[m]：";
            // 
            // zdzs
            // 
            this.zdzs.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.zdzs.Location = new System.Drawing.Point(748, 40);
            this.zdzs.Name = "zdzs";
            this.zdzs.Size = new System.Drawing.Size(80, 22);
            this.zdzs.TabIndex = 30;
            // 
            // label1
            // 
            this.label1.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label1.Location = new System.Drawing.Point(403, 40);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(226, 24);
            this.label1.TabIndex = 29;
            this.label1.Text = "发动机最大功率时的转速(n/min)：";
            // 
            // zgcs
            // 
            this.zgcs.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.zgcs.Location = new System.Drawing.Point(307, 40);
            this.zgcs.Name = "zgcs";
            this.zgcs.Size = new System.Drawing.Size(80, 22);
            this.zgcs.TabIndex = 28;
            // 
            // label5
            // 
            this.label5.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label5.Location = new System.Drawing.Point(24, 40);
            this.label5.Name = "label5";
            this.label5.Size = new System.Drawing.Size(192, 24);
            this.label5.TabIndex = 27;
            this.label5.Text = "期望最高车速(km/h)：";
            // 
            // m_OK
            // 
            this.m_OK.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.m_OK.Location = new System.Drawing.Point(670, 25);
            this.m_OK.Name = "m_OK";
            this.m_OK.Size = new System.Drawing.Size(75, 25);
            this.m_OK.TabIndex = 12;
            this.m_OK.Text = "计  算";
            this.m_OK.UseVisualStyleBackColor = false;
            this.m_OK.Click += new System.EventHandler(this.m_OK_Click);
            // 
            // panel4
            // 
            this.panel4.Controls.Add(this.m_OK);
            this.panel4.Controls.Add(this.m_Cancel);
            this.panel4.Location = new System.Drawing.Point(3, 337);
            this.panel4.Name = "panel4";
            this.panel4.Size = new System.Drawing.Size(890, 64);
            this.panel4.TabIndex = 15;
            // 
            // m_Cancel
            // 
            this.m_Cancel.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.m_Cancel.Location = new System.Drawing.Point(758, 25);
            this.m_Cancel.Name = "m_Cancel";
            this.m_Cancel.Size = new System.Drawing.Size(75, 25);
            this.m_Cancel.TabIndex = 13;
            this.m_Cancel.Text = "取  消";
            this.m_Cancel.UseVisualStyleBackColor = false;
            this.m_Cancel.Click += new System.EventHandler(this.m_Cancel_Click);
            // 
            // panel3
            // 
            this.panel3.Controls.Add(this.groupBox2);
            this.panel3.Location = new System.Drawing.Point(3, 213);
            this.panel3.Name = "panel3";
            this.panel3.Size = new System.Drawing.Size(890, 118);
            this.panel3.TabIndex = 2;
            // 
            // groupBox2
            // 
            this.groupBox2.Controls.Add(this.label25);
            this.groupBox2.Controls.Add(this.label4);
            this.groupBox2.Controls.Add(this.jxsu);
            this.groupBox2.Controls.Add(this.yhjg);
            this.groupBox2.Controls.Add(this.label6);
            this.groupBox2.Controls.Add(this.jdsu);
            this.groupBox2.Font = new System.Drawing.Font("新宋体", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.groupBox2.Location = new System.Drawing.Point(0, 3);
            this.groupBox2.Name = "groupBox2";
            this.groupBox2.Size = new System.Drawing.Size(887, 115);
            this.groupBox2.TabIndex = 0;
            this.groupBox2.TabStop = false;
            this.groupBox2.Text = "计算结果显示：";
            // 
            // label25
            // 
            this.label25.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label25.Location = new System.Drawing.Point(24, 72);
            this.label25.Name = "label25";
            this.label25.Size = new System.Drawing.Size(192, 16);
            this.label25.TabIndex = 49;
            this.label25.Text = "优化结果：";
            // 
            // yhjg
            // 
            this.yhjg.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.yhjg.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.yhjg.Location = new System.Drawing.Point(307, 72);
            this.yhjg.Name = "yhjg";
            this.yhjg.ReadOnly = true;
            this.yhjg.Size = new System.Drawing.Size(80, 22);
            this.yhjg.TabIndex = 50;
            // 
            // jjxjqxs
            // 
            this.jjxjqxs.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.jjxjqxs.Location = new System.Drawing.Point(747, 154);
            this.jjxjqxs.Name = "jjxjqxs";
            this.jjxjqxs.Size = new System.Drawing.Size(80, 22);
            this.jjxjqxs.TabIndex = 46;
            // 
            // panel1
            // 
            this.panel1.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D;
            this.panel1.Controls.Add(this.panel4);
            this.panel1.Controls.Add(this.panel3);
            this.panel1.Controls.Add(this.panel2);
            this.panel1.Location = new System.Drawing.Point(0, 0);
            this.panel1.Name = "panel1";
            this.panel1.Size = new System.Drawing.Size(900, 628);
            this.panel1.TabIndex = 2;
            // 
            // panel2
            // 
            this.panel2.Controls.Add(this.groupBox1);
            this.panel2.Location = new System.Drawing.Point(3, 0);
            this.panel2.Name = "panel2";
            this.panel2.Size = new System.Drawing.Size(890, 207);
            this.panel2.TabIndex = 1;
            // 
            // groupBox1
            // 
            this.groupBox1.Controls.Add(this.jjxjqxs);
            this.groupBox1.Controls.Add(this.label10);
            this.groupBox1.Controls.Add(this.dlxzb);
            this.groupBox1.Controls.Add(this.label9);
            this.groupBox1.Controls.Add(this.jjxzb);
            this.groupBox1.Controls.Add(this.label8);
            this.groupBox1.Controls.Add(this.dlxjqxs);
            this.groupBox1.Controls.Add(this.label7);
            this.groupBox1.Controls.Add(this.zdsb);
            this.groupBox1.Controls.Add(this.label3);
            this.groupBox1.Controls.Add(this.gdbj);
            this.groupBox1.Controls.Add(this.label2);
            this.groupBox1.Controls.Add(this.zdzs);
            this.groupBox1.Controls.Add(this.label1);
            this.groupBox1.Controls.Add(this.zgcs);
            this.groupBox1.Controls.Add(this.label5);
            this.groupBox1.Font = new System.Drawing.Font("新宋体", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.groupBox1.Location = new System.Drawing.Point(0, 0);
            this.groupBox1.Name = "groupBox1";
            this.groupBox1.Size = new System.Drawing.Size(887, 196);
            this.groupBox1.TabIndex = 0;
            this.groupBox1.TabStop = false;
            this.groupBox1.Text = "主减速器优化参数输入";
            // 
            // label10
            // 
            this.label10.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label10.Location = new System.Drawing.Point(402, 154);
            this.label10.Name = "label10";
            this.label10.Size = new System.Drawing.Size(192, 24);
            this.label10.TabIndex = 45;
            this.label10.Text = "经济性加权系数：";
            // 
            // dlxzb
            // 
            this.dlxzb.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.dlxzb.Location = new System.Drawing.Point(306, 114);
            this.dlxzb.Name = "dlxzb";
            this.dlxzb.Size = new System.Drawing.Size(80, 22);
            this.dlxzb.TabIndex = 44;
            // 
            // label9
            // 
            this.label9.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.label9.Location = new System.Drawing.Point(24, 114);
            this.label9.Name = "label9";
            this.label9.Size = new System.Drawing.Size(288, 24);
            this.label9.TabIndex = 43;
            this.label9.Text = "动力性指标（以原地起步加速时间为目标）：";
            // 
            // jjxzb
            // 
            this.jjxzb.Font = new System.Drawing.Font("新宋体", 9.75F);
            this.jjxzb.Location = new System.Drawing.Point(747, 114);
            this.jjxzb.Name = "jjxzb";
            this.jjxzb.Size = new System.Drawing.Size(80, 22);
            this.jjxzb.TabIndex = 42;
            // 
            // usCtlHouQiaoYHPP
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.BackColor = System.Drawing.SystemColors.ActiveBorder;
            this.Controls.Add(this.panel1);
            this.Font = new System.Drawing.Font("新宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
            this.Name = "usCtlHouQiaoYHPP";
            this.Size = new System.Drawing.Size(1005, 468);
            this.Load += new System.EventHandler(this.usCtlHouQiaoYHPP_Load);
            this.panel4.ResumeLayout(false);
            this.panel3.ResumeLayout(false);
            this.groupBox2.ResumeLayout(false);
            this.groupBox2.PerformLayout();
            this.panel1.ResumeLayout(false);
            this.panel2.ResumeLayout(false);
            this.groupBox1.ResumeLayout(false);
            this.groupBox1.PerformLayout();
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.Label label8;
        private System.Windows.Forms.TextBox dlxjqxs;
        private System.Windows.Forms.Label label7;
        private System.Windows.Forms.TextBox jdsu;
        private System.Windows.Forms.Label label6;
        private System.Windows.Forms.TextBox jxsu;
        private System.Windows.Forms.Label label4;
        private System.Windows.Forms.TextBox zdsb;
        private System.Windows.Forms.Label label3;
        private System.Windows.Forms.TextBox gdbj;
        private System.Windows.Forms.Label label2;
        private System.Windows.Forms.TextBox zdzs;
        private System.Windows.Forms.Label label1;
        private System.Windows.Forms.TextBox zgcs;
        private System.Windows.Forms.Label label5;
        private System.Windows.Forms.Button m_OK;
        private System.Windows.Forms.Panel panel4;
        private System.Windows.Forms.Button m_Cancel;
        private System.Windows.Forms.Panel panel3;
        private System.Windows.Forms.GroupBox groupBox2;
        private System.Windows.Forms.Label label25;
        private System.Windows.Forms.TextBox yhjg;
        private System.Windows.Forms.TextBox jjxjqxs;
        private System.Windows.Forms.Panel panel1;
        private System.Windows.Forms.Panel panel2;
        private System.Windows.Forms.GroupBox groupBox1;
        private System.Windows.Forms.Label label10;
        private System.Windows.Forms.TextBox dlxzb;
        private System.Windows.Forms.Label label9;
        private System.Windows.Forms.TextBox jjxzb;

        public usCtlHouQiaoYHPP()
        {
            InitializeComponent();
        }

        private void m_OK_Click(object sender, EventArgs e)
        {
            ComputeData();
        }
        private bool InspectionText(TextBox text)
        {
            if (string.Empty == text.Text.Trim())
                return false;
            return true;
        }

        protected bool TestContent()
        {
            if (!InspectionText(this.zdzs))
                return false;
            if (!InspectionText(this.zgcs))
                return false;
            if (!InspectionText(this.zdsb))
                return false;
            return true;
        }

        private void ComputeData()
        {
            if (!TestContent())
            {
                MessageBox.Show("请将参数填写完整。", "提示！");
                return;
            }
            double dZdzs,dZgcs,dZdsb,dGdbj,dJxsu,dJdsu;

            dZdzs = double.Parse(this.zdzs.Text);
            dZgcs = double.Parse(this.zgcs.Text);
            dZdsb = double.Parse(this.zdsb.Text);
            dGdbj = double.Parse(this.gdbj.Text);

            dJxsu = 0.377 * dZdzs * dGdbj / dZdsb / dZgcs;
            dJdsu = 0.472 * dZdzs * dGdbj/ dZdsb/ dZgcs;
            this.jxsu.Text = StringParse.FormatNumberDot01((float)dJxsu);
            this.jdsu.Text = StringParse.FormatNumberDot01((float)dJdsu);

            double dDlxzb,dJjxzb,dDlxjqxs,dJjxjqxs,dYhjg;
            	
            dDlxzb = double.Parse(this.dlxzb.Text);
            dJjxzb = double.Parse(this.jjxzb.Text);
            dDlxjqxs = double.Parse(this.dlxjqxs.Text);
            dJjxjqxs = double.Parse(this.jjxjqxs.Text);
            dYhjg = dJxsu * dDlxjqxs + dJdsu * dJjxjqxs;
		    if(dDlxjqxs == 1.0|| dJjxjqxs == 1.0){
			    dYhjg = (dJxsu + dJdsu) / 2.0 ;
            }
            this.yhjg.Text = StringParse.FormatNumberDot01((float)dYhjg);

        }

        private void InitData()
        {
            this.zgcs.Text = "140";
            this.zdzs.Text = "3600";
            this.gdbj.Text = "0.375";
            this.zdsb.Text = "0.802";
            this.dlxzb.Text = "0";
            this.jjxzb.Text = "0";
            this.dlxjqxs.Text = "0";
            this.jjxjqxs.Text = "0";

            this.jxsu.Text = "0";
            this.jdsu.Text = "0";
            this.yhjg.Text = "0";
        }

        private void m_Cancel_Click(object sender, EventArgs e)
        {
            InitData();
        }

        private void usCtlHouQiaoYHPP_Load(object sender, EventArgs e)
        {
            InitData();
        }

        #region 画面的计算按钮动作		
		/// <summary>
		/// 计算按钮
		/// </summary>
		/// <author></author>
		override public void Compute()
		{
			ComputeData();
		}
		#endregion	
	}
}
